<?php

namespace App\Http\Requests\Entity\Asset\Video;


use App\Http\Requests\Request;

class VassetiRequest extends Request
{

    /**
     * Determine if the user is authorized to make this request.
     *
     * @return bool
     */
    public function authorize()
    {
        return true;
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array
     */
    public function rules()
    {
        switch ($this->method()) {
            case 'GET':
            case 'DELETE':
                {
                    return [];
                }
            // Crate
            case 'POST':
                {
                    return [
                        'vasseti_no'        => 'required|max:100|unique:vassetis,vasseti_no',
                        'name'              => 'required|max:100',
                        'title'             => 'max:100',
                        'subtitle'          => 'max:100',
                        'score'             => 'numeric',
                        'season'            => 'numeric',
                        'episode'           => 'numeric',
                        'vcat_id'           => 'required|max:10',
                        // 'vyear_id'      => 'required|max:10',
                        // 'varea_id'          => 'required|max:100',
                        // 'vlang_id'          => 'required|max:50',
                        // 'resolution_id' => 'required|max:10',
                        'short_desc'    => 'required',
                        'charge_type' => 'required',
                        'listorder'  => 'required',
                        'vasseti_type' => 'required',
                    ];
                }
            // UPDATE
            case 'PUT':
            case 'PATCH':
                {
                    $id = $this->route('vassetis');
                    return [
                        'vasseti_no'        => 'required|max:100|unique:vassetis,vasseti_no,' . $id,
                        'name'              => 'required|max:100',
                        'title'             => 'max:100',
                        'subtitle'          => 'max:100',
                        'score'             => 'numeric',
                        'season'            => 'numeric',
                        'episode'           => 'numeric',
                        'vcat_id'           => 'required|max:10',
                        // 'vyear_id'      => 'required|max:10',
                        // 'varea_id'          => 'required|max:100',
                        // 'vlang_id'          => 'required|max:50',
                        // 'resolution_id' => 'required|max:10',
                        'short_desc'    => 'required',
                        'charge_type' => 'required',
                        'listorder'  => 'required',
                        'vasseti_type' => 'required',
                    ];
                }
            default:
                break;
        }
    }
     public function messages()
    {
        return [
            'vasseti_no.required' => '编号 不能为空',
            'name.required'       => '名称 不能为空',
            'short_desc.required' => '简介 不能为空',
            'title.max'           => '标题 不能大于100个字符',
            'subtitle.max'        => '副标题 不能大于100个字符',
            'vcat_id.required'    => '归类 不能为空',
            'charge_type.required' => '收费类型 不能为空',
            'vasseti_type.required' => '剧集类型 不能为空',   

        ];
    }
}
